package net.xiduth.game.player.content.events.objects;

import net.xiduth.game.WorldObject;
import net.xiduth.game.WorldTile;
import net.xiduth.game.player.Player;
import net.xiduth.game.tasks.WorldTask;
import net.xiduth.game.tasks.WorldTasksManager;

/**
 * 
 * @author Jae <jae@xiduth.com>
 * 
 * @since <Oct 21, 2013>
 *
 */
public class StrongholdHandler {
	
	public static final WorldTile FLOOR_1 = new WorldTile(1860,
			5243, 0);
	
	public static final WorldTile FLOOR_2 = new WorldTile(2043,
			5243, 0);
	
	public static final WorldTile FLOOR_3 = new WorldTile(2123,
			5253, 0);
	
	public static final WorldTile FLOOR_4 = new WorldTile(2310,
			5238, 0);
	
	public static void sendLookAnim() {
		//TODO
	}
	
	/** Gift of Peace ID: 16135 **/
	public static void openGiftOfPeace(final Player player,
			WorldObject object) { 
		if (player.finishedFloor1 = false) {
			player.getDialogueManager().startDialogue("SimpleMessage", "You search the chest and find 2,000 coins.");
			player.getMoneyPouch().add(2000);
			player.finishedFloor1 = true;
		} else {
			player.getDialogueManager().startDialogue("SimpleMessage", "Nothing interesting happens.");
		}
	}
	
	/** Grain of Plenty ID: 16077 **/
	public static void openGrainOfPlenty(final Player player,
			WorldObject object) {
		if (player.finishedFloor2 = false) {
			player.getDialogueManager().startDialogue("SimpleMessage", "You search the sack and find 3,000 coins.");
			player.getMoneyPouch().add(3000);
			player.finishedFloor2 = true;
		} else {
			player.getDialogueManager().startDialogue("SimpleMessage", "Nothing interesting happens.");
		}
	}
	
	/** Box of Health ID: 16118 **/
	public static void openBoxOfHealth(final Player player,
			WorldObject object) {
		if (player.finishedFloor3 = false) {
			player.getDialogueManager().startDialogue("SimpleMessage", "You search the box and find 5,000 coins.");
			player.getMoneyPouch().add(5000);
			player.finishedFloor3 = true;
		} else {
			player.getDialogueManager().startDialogue("SimpleMessage", "Nothing interesting happens.");
		}
	}
	
	/** Cradle of Life ID: 16047 **/
	public static void openCradleOfLife(final Player player,
			WorldObject object) {
		if (player.finishedFloor4 = false) {
			player.getDialogueManager().startDialogue("SimpleMessage", "The cradle prompts you to pick a reward.");
			WorldTasksManager.schedule(new WorldTask() {
				@Override
				public void run() {
					player.getDialogueManager().startDialogue("StrongholdBoots");
				}
			}, 2);
			player.finishedFloor4 = true;
		} else {
			player.getDialogueManager().startDialogue("SimpleMessage", "Nothing interesting happens.");
		}
	}
	
	/** Floor 1 portal ID: 16150 **/
	public static void useFloor1Portal(final Player player, 
			final WorldObject object) {
		if (player.finishedFloor1 = true) {
			player.move(new WorldTile (FLOOR_2));
		} else {
			player.sm("You don't have the privileges to use this.");
		}
	}
	
	/** Right door object ID: 16123 **/
	public static void handleFloor1RightObjects(final Player player, 
			final WorldObject object) {
		if (player.getX() == 1858 && player.getY() == 5239) {
			player.move(new WorldTile (1858, 5238, 0));
			sendLookAnim();
		}
		if (player.getX() == 1858 && player.getY() == 5236) {
			player.move(new WorldTile (1858, 5325, 0));
			sendLookAnim();
		}
		if (player.getX() == 1864 && player.getY() == 5226) {
			player.move(new WorldTile (1865, 5226, 0));
			sendLookAnim();
		}
		if (player.getX() == 1865 && player.getY() == 5226) {
			player.move(new WorldTile (1864, 5226, 0));
			sendLookAnim();
		}
	}

}
